<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--{include file='comm/header.tpl'}-->
    <title>角色组列表</title>
</head>

<body>

<div class="container">

   
        <div class="comm_content">

            <table id="flex" style="display:none"></table>

        </div>


</div>


<div id="pop" style="display: none;">

    <form class="form-horizontal" id="editForm" onsubmit="return false;">

        <div class="form-group">
            <label for="roleGroupName" class="col-sm-3 control-label"><span class="red">*</span> 角色组名称：</label>
            <div class="col-sm-9">
                <input type="text" class="form-control w150" id="roleGroupName" name="roleGroupName" placeholder="请输入角色组名称">
            </div>
        </div>

        <div class="form-group">
            <label for="memo" class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-9">
                <textarea class="form-control w300" id="memo" name="memo" placeholder="请输入备注"></textarea>
                <input type="hidden" name="roleGroupID" id="roleGroupID" value="0" />
            </div>
        </div>

    </form>

</div>


</body>
<script type="text/javascript">

	$("#flex").flexigrid({
        url:"/invokingAjax-backend/system/roleGroupList.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            <!--{if $edit_permission}-->
            {display: "操作", width : 100, align: 'center'},
            <!--{/if}-->
            {display: "角色组ID", name : "roleGroupID" , width : 150 , sortable : true },
            {display: "角色组名称", width : 200},
            {display: "备注", width : 500}
        ],
        <!--{if $edit_permission}-->
        buttons : [
            {name: "添加", bclass: "add", onpress : "roleGroup.edit.open"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "roleGroup.del.check"},
            {separator: true},
            {name: "全选", bclass: "checkAll", onpress : "E.checkAllList"},
            {separator: true},
            {name: "取消全选", bclass: "cancelCheckAll", onpress : "E.cancelCheckAllList"}
        ],
        <!--{/if}-->
        sortname: "roleGroupID",
        sortorder: "DESC",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true
    });
		
	var roleGroup = {

        //查询角色组详细信息
        detail: {

            search: function( id ) {

                E.loadding.open('正在查询，请稍候...');

                E.ajax_get({
                    url: "/invokingAjax-backend/system/roleGroupList.ajax?operFlg=2",
                    data: {
                        id: id
                    },
                    call: "roleGroup.detail.result"
                });

            },

            result: function( o ) {

                E.loadding.close();

                if (o.code == 200) {
                    $('#roleGroupID').val(o.data.roleGroupID);
                    $('#roleGroupName').val(o.data.roleGroupName);
                    $('#memo').val(o.data.memo);
                } else {
                    E.popup.close();
                    E.alert(o.message);
                }

            }

        },

		edit: {

            open: function( id ) {

                if (!id) id = 0;

                E.popup.open({
                    id:"pop",
                    title: id == 0 ? '新增角色组' : '修改角色组',
                    css: "width: 600px;",
                    btnName: "保存",
                    btnCall:"roleGroup.edit.execute();" //
                });

                if (id > 0) {
                    roleGroup.detail.search( id );
                }

            },

            execute: function() {

                this.dt = E.getFormValues('editForm');

                if (E.isEmpty(this.dt.roleGroupName)) {

                    E.alert('角色组名称不能为空');

                } else {

                    E.loadding.open('正在保存，请稍候...');

                    E.ajax_get({
                        url: "/invokingAjax-backend/system/roleGroupList.ajax?operFlg=100&act=edit",
                        data: this.dt,
                        call: "roleGroup.edit.result"
                    });

                }

            },

            result: function( o ) {

                E.loadding.close();

                if (o.code == 200) {

                    roleGroup.load();

                    if (this.dt.roleGroupID > 0) {

                        E.alert(o.message, 2, 'E.popup.close');

                    } else {

                        document.getElementById('editForm').reset();
                        E.alert(o.message, 2);

                    }
                } else {

                    E.alert(o.message);

                }

            }

		},

		load: function(){
			$("#flex").flexReload();
		},

        del: {

            g_array: "",

            check: function() {

                this.g_array = new Array();

                //获取选中的行的行数
                var selected_count=$('.trSelected',flex).length;
                if (selected_count==0) {
                    E.alert('请选择要删除的角色组');
                } else {
                    for(var i=0; i<selected_count; i++){
                        var typeIDStr = $('.trSelected',flex).eq(i).attr('id');
                        this.g_array.push(typeIDStr.substr(3));
                    }
                    //弹出确认层
                    E.confirm('您确认删除选择的角色组吗？', "roleGroup.del.execute");
                }
            },

            execute: function() {
                E.loadding.open('正在删除，请稍候...');
                E.ajax_get({
                    url: "/invokingAjax-backend/system/roleGroupList.ajax?operFlg=100&act=del",
                    data: {
                        r_g_array: this.g_array
                    },
                    call: "roleGroup.del.result"
                });
            },

            result: function( o ) {

                E.loadding.close();

                if (o.code == 200) {

                    E.alert(o.message, 2, 'roleGroup.load');

                } else {

                    E.alert(o.message);

                }

            }

        }
	};
</script>
</html>